package com.youdoneed.user.feign;

import com.youdoneed.base.application.ResultMessage;
import com.youdoneed.base.pagination.Page;
import com.youdoneed.user.model.CoolfaceNotice;
import com.youdoneed.user.model.FocusRegion;
import com.youdoneed.user.model.User;
import com.youdoneed.user.vo.ContactUser;
import com.youdoneed.user.vo.UserBasicInfo;
import com.youdoneed.user.vo.UserShow;
import com.youdoneed.user.vo.UserStatistics;
import io.swagger.annotations.ApiOperation;
import org.springframework.cloud.netflix.feign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 说明。
 *
 * @author Ewing
 * @date 2017/4/26
 */
@FeignClient(value = "user", fallback = UserFallback.class)
public interface UserFeignClient {

    /**
     * 根据手机号查询用户。
     */
    @RequestMapping(value = "/user/findByPhoneNo", method = RequestMethod.POST)
    ResultMessage<User> findByPhoneNo(@RequestParam("phoneNo") String phoneNo);

    /**
     * 根据手机号查询用户，支持多个手机号。
     */
    @RequestMapping(value = "/user/findByPhoneNos", method = RequestMethod.POST)
    ResultMessage<List<User>> findByPhoneNos(@RequestBody String[] phoneNos);

    /**
     * 根据手机号查询用户，支持多个手机号。
     */
    @RequestMapping(value = "/user/findUserIdsByPhoneNos", method = RequestMethod.POST)
    ResultMessage<List<String>> findUserIdsByPhoneNos(@RequestBody String[] phoneNos);

    /**
     * 根据UserId获取用户信息。
     */
    @RequestMapping(value = "/user/getUser", method = RequestMethod.GET)
    ResultMessage<User> getUser(@RequestParam("userId") String userId);

    /**
     * 根据多个UserId获取用户信息。
     */
    @RequestMapping(value = "/user/getUsers", method = RequestMethod.POST)
    ResultMessage<List<User>> getUsers(@RequestParam("userIds") String[] userIds);

    /**
     * 查找用户并分页。
     */
    @RequestMapping(value = "/user/findUsers", method = RequestMethod.POST)
    ResultMessage<Page<User>> findUsers(@RequestParam("offset") int offset,
                                        @RequestParam("limit") int limit, @RequestParam("count") boolean count,
                                        @RequestParam("name") String name);

    /**
     * 查询给定的ID范围内的用户。
     */
    @RequestMapping(value = "/user/findInUserIds", method = RequestMethod.POST)
    ResultMessage<List<UserBasicInfo>> findInUserIds(@RequestParam("userIds") String[] userIds,
                                                     @RequestParam("name") String name);

    /**
     * 别人是否能查看我的好友。
     */
    @RequestMapping(value = "/user/isCanSeeMyFriends", method = RequestMethod.POST)
    ResultMessage<Boolean> isCanSeeMyFriends(@RequestParam("userId") String userId, @RequestParam("otherId") String otherId);

    /**
     * 改变用户的帖子总数。
     */
    @RequestMapping(value = "/user/changeStatistics", method = RequestMethod.POST)
    ResultMessage totalArticleChange(@RequestParam("userId") String userId, @RequestParam("totalArticleChange") Integer totalArticleChange);

    /**
     * 改变用户的好友总数。
     */
    @RequestMapping(value = "/user/changeStatistics", method = RequestMethod.POST)
    ResultMessage totalFriendChange(@RequestParam("userId") String userId, @RequestParam("totalFriendChange") Integer totalFriendChange);

    /**
     * 管理员统计用户信息。
     */
    @RequestMapping(value = "/admin/userStatistics", method = RequestMethod.POST)
    ResultMessage<UserStatistics> userStatistics();

    /**
     * 判断用户的通讯录的号码今天是否已邀请。
     */
    @RequestMapping(value = "/user/hasInvitedToday", method = RequestMethod.POST)
    ResultMessage<List<String>> hasInvitedToday(@RequestBody String[] otherPhoneNos);

    /**
     * 附近的用户。
     */
    @RequestMapping(value = "/user/nearbyUsers", method = RequestMethod.POST)
    ResultMessage<List<UserShow>> nearbyUsers(
            @RequestParam("offset") int offset, @RequestParam("limit") int limit,
            @RequestParam("longitude") Double longitude, @RequestParam("latitude") Double latitude,
            @RequestParam("maxDistance") Integer maxDistance,@RequestParam("forAddFriend") Boolean forAddFriend);

    /**
     * 获取用户的所有关注区域。
     */
    @RequestMapping(value = "/focusRegion/checkedFocusRegion", method = RequestMethod.POST)
    ResultMessage<FocusRegion> checkedFocusRegion();

    /**
     * 获取用户的所有关注区域。
     */
    @RequestMapping(value = "/user/getRecommandUsers", method = RequestMethod.POST)
    ResultMessage<List<User>> getRecommandUsers();

    /**
     * 获取用户通讯录中已注册的用户。
     */
    @RequestMapping(value = "/user/getContactUsers", method = RequestMethod.POST)
    ResultMessage<List<ContactUser>> getContactUsers();

    /**
     * 保存coolface通知
     */
    @RequestMapping(value = "/coolfaceNotice/saveNotice", method = RequestMethod.POST)
    ResultMessage<?> saveNotice(CoolfaceNotice coolfaceNotice);

    /**
     * 获取我的coolface通知
     * @return ResultMessage
     * @author lid
     * @date 2017.11.14
     */
    @RequestMapping(value = "/coolfaceNotice/getNotice", method = RequestMethod.POST)
    ResultMessage<List<CoolfaceNotice>> getNotice();

    /**
     * 将我的消息设置为已读
     * @return ResultMessage
     * @author lid
     * @date 2017.11.14
     */
    @RequestMapping(value = "/coolfaceNotice/readCoolfaceNotice", method = RequestMethod.POST)
    ResultMessage<?> readCoolfaceNotice(@RequestParam("noticeId") String noticeId);

    /**
     * 获取所有用户
     * @return ResultMessage
     * @author lid
     * @date 2017.11.14
     */
    @RequestMapping(value = "/user/getAllUser", method = RequestMethod.GET)
    ResultMessage<List<User>> getAllUser();
}
